<?php
//class App_Plugin_Meta extends Zend_Application_Resource_ResourceAbstract{
class App_Plugin_Meta extends Zend_Controller_Plugin_Abstract{

    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
    }

    public function postDispatch(Zend_Controller_Request_Abstract $request) {
        if ($this->getRequest()->isXmlHttpRequest()) return false;

        // Set title, keywords and description
        $layout = Zend_Layout::getMvcInstance();
        $view = $layout->getView();

        $meta = new \Managers\Meta();
        $meta_info = $meta->getMeta($this->getRequest(), &$view);
        //обнуляем тайтл на случай внутренних редиректов
        $view->headTitle()->setContainer(new \Zend_View_Helper_Placeholder_Container);
        $view->headMeta()->setContainer(new \Zend_View_Helper_Placeholder_Container);

        $view->headTitle($meta_info['title']);
        $view->headMeta($meta_info['description'], 'description');
        $view->headMeta($meta_info['keywords'], 'keywords');

    }
}